<template>
    <div class="SignIn">
<!--        <div id="qrcode"></div> &lt;!&ndash; 创建一个div，并设置id为qrcode &ndash;&gt;-->
<!--        <el-upload-->
<!--                class="upload-demo"-->
<!--                action="http://localhost:8080/Departments/file"-->
<!--                :on-preview="handlePreview"-->
<!--                :on-remove="handleRemove"-->
<!--                :file-list="fileList"-->
<!--                list-type="picture" >-->
<!--            <el-button size="small" type="primary">点击上传</el-button>-->
<!--            <div slot="tip" class="el-upload__tip">只能上传jpg/png文件，且不超过500kb</div>-->
<!--        </el-upload>-->
        <!--        面包导航-->
        <el-breadcrumb separator-class="el-icon-arrow-right">
            <el-breadcrumb-item :to="{ path: '/home' }">首页</el-breadcrumb-item>
            <el-breadcrumb-item>签到管理</el-breadcrumb-item>
            <el-breadcrumb-item>签到</el-breadcrumb-item>
        </el-breadcrumb>
        <!--        卡片-->
        <el-card class="box-card" >
            <div style="margin-top: 2px" v-if="this.code === 1">
                <el-button type="primary" @click="sign()">签到</el-button>
            </div>
        </el-card>
    </div>
</template>

<script>
    import QRCode from 'qrcodejs2'
    export default {
        name: "SignIn",
        data(){
            return{
                code: 0
            }
        },
        mounted () {
            // this.qrcode()
        },
        created() {
            this.getStatues()
        },
        methods: {
           async getStatues(){
                const {data: res} = await this.$http.get('Sign/setSignByopen',{
                    params:{
                        id: window.sessionStorage.getItem('id')
                    }
                })
               if(res.code === 104){
                   return this.$message.info(res.message)
               }else if(res.code === 105){
                   return this.$message.info(res.message)
               }else {
                   this.code = 1
               }

            },
            // qrcode() {
            //     let qrcode = new QRCode('qrcode', {
            //         width: 132,
            //         height: 132,
            //         text: 'https://www.baidu.com', // 二维码地址
            //     })
            // },
           async sign(){
               console.log('asdsadasd')
                const {data: res} = await this.$http.get('Dormitory/updateUserSign',{
                    params:{
                        id: window.sessionStorage.getItem('id')
                    }
                })
               if(res.code !==0) return this.$message.error(res.message)
               this.$message.success(res.message)
               this.$router.go(0)
            }
        }
    }
</script>

<style scoped>

</style>